package oj;

public class FindKth {
    public ListNode FindKthToTail (ListNode pHead, int k) {
        if(pHead ==  null){
            return null;
        }
        if(k <= 0){
            return null;
        }

        ListNode fast = pHead;
        ListNode slow = pHead;
        int count = 0;
        while(count != k - 1) {
            fast = fast.next;
            if(fast == null){
                return null;
            }
            count++;
        }
        while(fast.next != null){
            slow = slow.next;
            fast = fast.next;
        }
        return slow;
    }
}
